{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">管理员</li>
            <li class=""><a href="{:url('admin/admin_user/add')}">添加管理员</a></li>
        </ul>
        <div class="layui-btn-group" style="margin-top: 10px;">
            <a href="{:url('admin/admin_user/export')}"><button class="layui-btn"> <i class="layui-icon"></i>导出管理员</button></a>
            <a href="#" style="margin-left: 10px"><button id="import" type="button" class="layui-btn layui-btn-primary"><i class="layui-icon"></i>导入管理员</button></a>
        </div>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th style="width: 30px;">ID</th>
                        <th>用户名</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>最后登录时间</th>
                        <th>最后登录IP</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name="admin_user_list" item="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.username}</td>
                        <td>{php}echo $vo['status']==1 ? '启用' : '禁用';{/php}</td>
                        <td>{$vo.create_time}</td>
                        <td>{$vo.last_login_time}</td>
                        <td>{$vo.last_login_ip}</td>
                        <td>
                            <a href="{:url('admin/admin_user/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-mini">编辑</a>
                            <a href="{:url('admin/admin_user/delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-danger layui-btn-mini ajax-delete">删除</a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<link href="__CSS__/cropper.css" rel="stylesheet">
<script src="__JS__/jquery.form.js"></script>
<script src="__JS__/cropper.min.js"></script>
<script src="__JS__/layui/layui.js"></script>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;

        upload.render({ //允许上传的文件后缀
            elem: '#import'
            ,url: '{:url(\'api/upload/upload\')}'
            ,data:{fileType:'excel'}
            ,accept: 'file' //普通文件
            ,exts: 'xls|zip' //只允许上传压缩文件
            ,done: function(res){
                if(res.error){
                    layer.alert(res.error);return
                }else{
                    console.log(res.url)
                    location.href= "{:url('admin/admin_user/import')}?file="+res.url;
                }
            }
        });
    });
</script>
{/block}
